package com.lmscn.lms.api.model;

import com.jfinal.plugin.activerecord.Model;

import java.util.List;

/**
 * Created by quxingyu on 2015/8/6.
 */
public class TestpaperItem extends Model<TestpaperItem> {
    public static final TestpaperItem dao = new TestpaperItem();
    /**
     * 查看每个试卷下有哪些题目，以及题目的选项
     * @param testpaperId 试卷ID
     * */
    public List<Question> getQuestionList(Long testpaperId){
        return Question.dao.find("select a.* from t_testpaper_item c,t_question a " +
                "where a.id = c.question_id and c.testpaper_id = ?",testpaperId);
    }

    /**
     * 根据问题Id,试卷Id
     * 查询试卷选项
     * @param testpaperId
     * @param questionId
     * @return
     */
    public TestpaperItem findByItemIdAndQuestionId(Long testpaperId,Long questionId){
        return TestpaperItem.dao.findFirst("select * from t_testpaper_item " +
                "where question_id = ? and testpaper_id = ? ",questionId,testpaperId);
    }

}
